package com.tsunami.exception.code;

/**
 * @Classname ExceptionCode
 * @Description TODO
 * @Date 2021-09-10 18:31
 * @Created by lx
 */
public enum ExceptionCode implements BaseExceptionCode {
    //公共请求消息
    SUCCESS(200,"请求成功"),
    TABLE_SUCCESS(0,"请求成功"),
    FATL(500,"请求失败"),
    OM_UNAUTHORIZED(3000,"运维权限，您无授权"),
    SUB_HAVE(3001,"下属数据不为空，无法执行操作"),
    ESCAPE_FATL(3002,"参数不符合规范，不能进行查询"),
    TIME_OUT(3003,"连接超时"),

    PARAMETER_MISSING(6000,"参数缺失"),
    ROLE_USEING(6001,"角色已被用户关联，无法删除"),
    ROLE_NULL(6002,"角色异常，请刷新重试"),
    ROLE_TYPE_ONLY(6003,"同用户类型只能绑定单角色"),
    ROLE_TYPE(6004,"选中角色为用户类型默认角色无法删除"),
    SUCCESS_NOROLE(6005,"用户添加成功，设置默认角色失败"),
    UNLOGIN(4001,"未登录"),
    UNAUTHORIZED(4003,"未授权"),
    CUSTOMER_ABNORMAL(4002,"租户异常，请刷新重试"),
    ARITHMETICEXCEPTION(4007,"算数异常"),
    CLONEEXCEPTION(4008,"克隆异常"),
    METHODEXCEPTION(4009,"请求方法异常"),
    TENANT_MASTER(4011,"主租户无法删除"),
    //会员
    NUMULTI(5006,"该会员组不支持多机构"),
    UNMEMBERCODE(5007,"会员编码不能为空"),

    UNMEMBERFEE(5008,"会员年费不能为空"),
    UNMEMBERNUM(5009,"限制数量不能为空"),
    ONMEMBER(5010,"会员说明已存在"),

    NOSAMEPASSWORD(7000,"两次输入密码不同"),
    USER_LOCK(7001,"账号已被停用"),
    USER_DEL(7002,"账号已被删除"),
    USER_HAVE(7003,"账号已存在"),
    NOPASSWORD(7004,"密码不能为空"),
    NOUSER(7005,"用户名不能为空"),
    EMAIL_HAVE(7006,"邮箱已经被使用"),
    PHONE_HAVE(7007,"手机号已经被使用"),
    EX_CAPTCHA(7008,"验证码异常"),
    NOUSER_NOPASSWORD(7009,"用户名或密码为空"),
    EX_USER_OR_PASSWORD(7010,"用户名或密码错误"),
    NO_USER(7005,"用户不存在"),
    AUTHENTICATION_FAIL(7011,"用户认证失败"),

    UPLOUD_FATL(8001,"上传失败"),

    //资源
    HAVE_CODE(9001,"编码已存在"),
    ;

    private int code;

    private String msg;

    ExceptionCode(int code, String msg){
        this.code = code;
        this.msg = msg;
    }


    @Override
    public int getCode() {
        return code;
    }

    @Override
    public String getMsg() {
        return msg;
    }
    public ExceptionCode build(String msg, Object... param) {
        this.msg = String.format(msg, param);
        return this;
    }

    public ExceptionCode param(Object... param) {
        msg = String.format(msg, param);
        return this;
    }
}
